<template>
  <div v-loading="formLoading" class="formBox height-100 p-rem-0">
    <el-form ref="form" class="formTable p-rem-t-24 p-rem-b-80" :model="form"
             :rules="viewJumpType=='form'?rules:{}" label-width="14rem">
      <div class="cardTitle p-rem-t-0">标题</div>
      <div class="cardContent">

        <el-row class="formRow">
          <el-col :span="12">
            <el-form-item label="输入框" prop="input">
              <el-input v-if="viewJumpType == 'form'" v-model.trim="form.input" placeholder="请输入" show-word-limit maxlength="100"></el-input>
              <span v-else>{{ form.input }}</span>
            </el-form-item>
          </el-col>

          <!--
            控制小数： v-input.float = {
              float 精确小数位 = 默认小数位数为0
              min 最小值(可输入负数） = 最小值为0
              max 最大值 = 最大值为1000000000
              zeroBool 是否可以输入0  =  默认true 可以输入0   false 不可以输入0
            }
          -->
          <el-col :span="12">
            <el-form-item label="输入数字" prop="digit">
                <el-input
                    v-if="viewJumpType=='form'"
                    v-model="form.digit"
                    v-input.float="{'float':2,'min':0,'max':100000000000000,zeroBool:false}"
                    placeholder="请输入"
                    type="number"
                    @focus="focusNumBerFun($event)"
                    @blur="blurNumBerFun($event,2,form,'digit')"
                ></el-input>
                <span v-else>{{ numberFormat(form.digit,2,'.',',','round') }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="下拉选择(单选)" prop="singleSelect">
              <el-select v-if="viewJumpType == 'form'" v-model.trim="form.singleSelect">
                <el-option
                    v-for="item in singleSelectOptions"
                    :key="item.dictValue"
                    :label="item.dictLabel"
                    :value="item.dictValue"
                ></el-option>
              </el-select>
              <span v-else>{{ getDictLabelMixins('singleSelectOptions',form.singleSelect) }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="下拉选择(多选)" prop="multipleSelect">
              <el-select v-if="viewJumpType == 'form'" v-model.trim="form.multipleSelect" multiple>
                <el-option
                  v-for="item in singleSelectOptions"
                  :key="item.dictValue"
                  :label="item.dictLabel"
                  :value="item.dictValue"
                ></el-option>
              </el-select>
              <span v-else>{{ getDictLabelMixins('singleSelectOptions',form.multipleSelect) }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="单选框" prop="radio">
              <el-radio-group v-if="viewJumpType == 'form'" v-model.trim="form.radio">
                <el-radio
                  v-for="item in singleSelectOptions"
                  :key="item.dictValue"
                  :label="item.dictValue"
                >
                  {{item.dictLabel}}
                </el-radio>
              </el-radio-group>
              <span v-else>{{ getDictLabelMixins('singleSelectOptions',form.radio) }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="复选框" prop="checkbox">
              <el-checkbox-group v-if="viewJumpType == 'form'" v-model.trim="form.checkbox">
                <el-checkbox
                  v-for="item in singleSelectOptions"
                  :key="item.dictValue"
                  :label="item.dictValue"
                >
                  {{ item.dictLabel }}
                </el-checkbox>
              </el-checkbox-group>
              <span v-else>{{ getDictLabelMixins('singleSelectOptions',form.checkbox) }}</span>
            </el-form-item>
          </el-col>

          <!-- 时间：
            type = year  单  -> 年
            type = month 单  -> 年/月
            type = date  单  -> 年/月/日
            ----------------------------------------------------------
            type = years  多  -> 年
            type = months 多  -> 年/月
            type = dates  多  -> 年/月/日
            ----------------------------------------------------------
            type = week -> 第几周
            ----------------------------------------------------------
            type = datetime -> 年/月/日 时:分:秒
            ----------------------------------------------------------
            type = datetimerange -> 区间值 年/月/日 时:分:秒
            type = daterange     -> 区间值 年/月/日
            type = monthrange    -> 区间值 年/月
            **************************************************************

          -->
          <el-col :span="12">
            <el-form-item label="日期" prop="date">
              <el-date-picker
                v-if="viewJumpType=='form'" v-model.trim="form.date" type="date" placeholder="请选择"
                value-format="yyyy-MM-dd" size="small"
              >
              </el-date-picker>
              <span v-else>  {{ parseTime( form.date ,'{y}-{m}-{d}') }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="时间" prop="time">
              <el-date-picker
                v-if="viewJumpType=='form'" v-model.trim="form.time" type="datetime" placeholder="请选择"
                format="yyyy-MM-dd HH:mm:ss"
                value-format="yyyy-MM-dd HH:mm:ss" size="small"
              >
              </el-date-picker>
              <span v-else> {{ parseTime( form.time ,'{y}-{m}-{d} {h}:{i}:{s}') }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="招标公告及报名开始时间" prop="signTime">
              <el-date-picker v-if="viewJumpType=='form'" v-model.trim="form.signTime" type="date" placeholder="请选择" value-format="yyyy-MM-dd" size="small" style="width:100%" @change="timeChangeFun(form,'start','招标公告及报名开始时间','signTime','招标公告及报名结束时间','signEndTime')"></el-date-picker>
              <span v-else>  {{ parseTime( form.signTime ,'{y}-{m}-{d}') }}</span>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="招标公告及报名结束时间" prop="signEndTime">
              <el-date-picker v-if="viewJumpType=='form'" v-model.trim="form.signEndTime" type="date" placeholder="请选择" value-format="yyyy-MM-dd" size="small" style="width:100%" @change="timeChangeFun(form,'end','招标公告及报名开始时间','signTime','招标公告及报名结束时间','signEndTime')"></el-date-picker>
              <span v-else>  {{ parseTime( form.signEndTime ,'{y}-{m}-{d}') }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="备注" prop="remark">
              <el-input
                  v-if="viewJumpType=='form'"
                  v-model="form.remark"
                  placeholder="请输入"
                  type="textarea"
                  rows="3"
                  show-word-limit maxlength="1000"
              ></el-input>
              <span v-else>{{ form.remark }}</span>
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="富文本编辑器" class="width-100" prop="content">
              <wangEitor
                  ref="wangEitor"
                  :readOnlyBool="viewJumpType == 'form' ? false : true"
                  :class="viewJumpType == 'form' ? '' : 'form-wang-eitor'"
                  class="width-100" />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

      <div class="cardTitle">图片上传</div>
      <div class="cardContent">
        <el-row class="formRow">
          <el-col :span="12">
            <el-form-item label="单传一张" prop="imageIds">
              <!-- 修改后：附件上传(混合超大附件 ji) -->
              <!-- uploadType  上传类型 image 图片 、 btnList 按钮 非表格附件list 、 btnTableList 按钮 表格附件list -->
              <uploadFile
                ref="uploadFile" uploaderName="image"
                uploadType="image" :uploadBtn="viewJumpType !== 'view'"
                btnTitle="上传报告" btnType="primary"
                :isAccept="true" :acceptArr="['.jpg','.png','.jpeg']"
                :multiple="false" :limit="1" :showList="true"
                :deleteBool="viewJumpType !== 'view'"
                :successList="form.imageList"
                @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','','','image')"
                @getFileList="(data)=>getFileTableListMixins(data,false,'form','','','image',false, 'image')"
              />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="多传" prop="imageMultipleIds">
              <!-- 修改后：附件上传(混合超大附件 ji) -->
              <!-- uploadType  上传类型 image 图片 、 btnList 按钮 非表格附件list 、 btnTableList 按钮 表格附件list -->
              <uploadFile
                ref="uploadFile" uploaderName="imageMultiple"
                uploadType="image" :uploadBtn="viewJumpType !== 'view'"
                btnTitle="上传报告" btnType="primary"
                :isAccept="true" :acceptArr="['.jpg','.png','.jpeg']"
                :multiple="true" :limit="1" :showList="true"
                :deleteBool="viewJumpType !== 'view'"
                :successList="form.imageMultipleList"
                @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','','','imageMultiple')"
                @getFileList="(data)=>getFileTableListMixins(data,false,'form','','','imageMultiple',true, 'image')"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </div>

      <div class="cardTitle">附件上传（自定义列表）</div>
      <div class="cardContent">
        <el-row class="formRow">
          <el-col :span="24">
            <el-form-item label="单传一个" prop="annexIds">
              <!-- 修改后：附件上传(混合超大附件 ji) -->
              <uploadFile
                ref="uploadFile" uploaderName="annex"
                uploadType="btnList" :uploadBtn="viewJumpType !== 'view'"
                btnTitle="上传报告" btnType="primary"
                :isAccept="true" :acceptArr="['.rar','.zip','.doc','.docx','.pdf','.xls','.xlsx','.jpg','.png','.jpeg']"
                :multiple="false" :limit="1" :showList="true"
                :deleteBool="viewJumpType !== 'view'"
                :successList="form.annexList"
                @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','','','annex')"
                @getFileList="(data)=>getFileTableListMixins(data,false,'form','','','annex',false, '')"
              />
            </el-form-item>
          </el-col>

          <el-col :span="24">
            <el-form-item label="多传" prop="annexMultipleIds">
              <!-- 修改后：附件上传(混合超大附件 ji) -->
              <!-- uploadType  上传类型 image 图片 、 btnList 按钮 非表格附件list 、 btnTableList 按钮 表格附件list -->
              <uploadFile
                ref="uploadFile" uploaderName="annexMultiple"
                uploadType="btnList" :uploadBtn="viewJumpType !== 'view'"
                btnTitle="上传报告" btnType="primary"
                :isAccept="true" :acceptArr="['.rar','.zip','.doc','.docx','.pdf','.xls','.xlsx','.jpg','.png','.jpeg']"
                :multiple="true" :limit="1" :showList="true"
                :deleteBool="viewJumpType !== 'view'"
                :successList="form.annexMultipleList"
                @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','','','annexMultiple')"
                @getFileList="(data)=>getFileTableListMixins(data,false,'form','','','annexMultiple',true, '')"
              />
            </el-form-item>
          </el-col>
        </el-row>
      </div>
      <div class="cardTitle">附件表格list</div>
      <div class="cardContent">
        <el-row>
          <el-col :span="24">
            <!-- 修改后：附件上传(混合超大附件 ji) -->
            <!-- uploadType  上传类型 image 图片 、 btnList 按钮 非表格附件list 、 btnTableList 按钮 表格附件list -->
            <uploadFile
              ref="uploadFile" uploaderName="annexOne"
              formItemProp="annexOneId"
              uploadType="btnTableList" :uploadBtn="viewJumpType !== 'view'"
              btnTitle="上传" btnType="primary"
              :isAccept="false" :acceptArr="['.rar','.zip','.doc','.docx','.pdf','.xls','.xlsx','.jpg','.png','.jpeg']"
              :multiple="true" :limit="1"
              :showList="true"
              :deleteBool="viewJumpType !== 'view'"
              :successList="form.annexOneList"
              @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','','','annexOne')"
              @getFileList="(data)=>getFileTableListMixins(data,false,'form','','','annexOne',true, '')"
            />
          </el-col>
        </el-row>
      </div>

      <div class="cardTitle">表格内</div>
      <div class="cardContent">
        <el-row>
          <el-col :span="24">
            <el-table
              ref="tableList"
              :data="form.tableList"
            >
              <!-- 序号 -->
              <el-table-column label="序号" type="index" width="80" align="center">
                <template slot-scope="scope">
                  {{ Number(scope.$index + 1) }}
                </template>
              </el-table-column>

              <!-- 输入框 -->
              <el-table-column label="输入框" prop="input" width="100">
                <template slot-scope="scope">
                  <el-form-item
                    v-if="viewJumpType == 'form'"
                    label="" label-width="0"
                    :prop="'tableList.'+scope.$index+'.input'"
                    :rules="formArrayRules.input" class="m-px-b-0"
                  >
                    <el-input v-model="scope.row.input" maxlength="20" placeholder="请输入"></el-input>
                  </el-form-item>
                  <span v-else>{{ scope.row.input }}</span>
                </template>
              </el-table-column>

              <!-- 输入数字 -->
              <el-table-column label="输入数字" prop="digit" width="100">
                <template slot-scope="scope">
                  <el-form-item
                    v-if="viewJumpType == 'form'"
                    label="" label-width="0"
                    :prop="'tableList.'+scope.$index+'.digit'"
                    :rules="formArrayRules.digit" class="m-px-b-0"
                  >
                    <el-input
                      v-model="scope.row.digit"
                      v-input.float="{'float':2,'min':0,'max':100000000000000}"
                      placeholder="请输入"
                      type="number"
                      @focus="focusNumBerFun($event)"
                      @blur="blurNumBerFun($event,2,scope.row,'digit')"
                    ></el-input>
                  </el-form-item>
                  <span v-else>{{ numberFormat(scope.row.digit,2,'.',',','round') }}</span>
                </template>
              </el-table-column>

              <!-- 下拉选择(单选) -->
              <el-table-column label="下拉选择(单选)" prop="singleSelect" width="100">
                <template slot-scope="scope">
                  <el-form-item
                    v-if="viewJumpType == 'form'"
                    label="" label-width="0"
                    :prop="'tableList.'+scope.$index+'.singleSelect'"
                    :rules="formArrayRules.singleSelect" class="m-px-b-0"
                  >
                    <el-select v-if="viewJumpType == 'form'" v-model.trim="scope.row.singleSelect">
                      <el-option
                        v-for="item in singleSelectOptions"
                        :key="item.dictValue"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                      ></el-option>
                    </el-select>
                  </el-form-item>
                  <span v-else>{{ getDictLabelMixins('singleSelectOptions',scope.row.singleSelect) }}</span>
                </template>
              </el-table-column>

              <!-- 下拉选择(多选) -->
              <el-table-column label="下拉选择(多选)" prop="multipleSelect" width="100">
                <template slot-scope="scope">
                  <el-form-item
                    v-if="viewJumpType == 'form'"
                    label="" label-width="0"
                    :prop="'tableList.'+scope.$index+'.multipleSelect'"
                    :rules="formArrayRules.multipleSelect" class="m-px-b-0"
                  >
                    <el-select v-if="viewJumpType == 'form'" v-model.trim="scope.row.multipleSelect">
                      <el-option
                        v-for="item in singleSelectOptions"
                        :key="item.dictValue"
                        :label="item.dictLabel"
                        :value="item.dictValue"
                      ></el-option>
                    </el-select>
                    <span v-else>{{ getDictLabelMixins('singleSelectOptions',scope.row.multipleSelect) }}</span>
                  </el-form-item>
                </template>
              </el-table-column>

              <!-- 日期 -->
              <el-table-column label="日期" prop="date" width="100">
                <template slot-scope="scope">
                  <el-form-item
                      v-if="viewJumpType == 'form'"
                      label="" label-width="0"
                      :prop="'tableList.'+scope.$index+'.date'"
                      :rules="formArrayRules.date" class="m-px-b-0"
                  >
                    <el-date-picker
                        v-model.trim="scope.row.date" type="date" placeholder="请选择"
                        format="yyyy-MM-dd" value-format="yyyy-MM-dd" size="small"
                    >
                    </el-date-picker>
                  </el-form-item>
                  <span v-else>  {{ parseTime( scope.row.date ,'{y}-{m}-{d}') }}</span>
                </template>
              </el-table-column>

              <!-- 时间 -->
              <el-table-column label="时间" prop="time" width="100">
                <template slot-scope="scope">
                  <el-form-item
                      v-if="viewJumpType == 'form'"
                      label="" label-width="0"
                      :prop="'tableList.'+scope.$index+'.time'"
                      :rules="formArrayRules.time" class="m-px-b-0"
                  >
                    <el-date-picker
                       v-model.trim="scope.row.time" type="datetime" placeholder="请选择"
                        format="yyyy-MM-dd HH:mm:ss"
                        value-format="yyyy-MM-dd HH:mm:ss" size="small"
                    >
                    </el-date-picker>
                  </el-form-item>
                  <span v-else> {{ parseTime( scope.row.time ,'{y}-{m}-{d} {h}:{i}:{s}') }}</span>
                </template>
              </el-table-column>

              <el-table-column label="图片单传一张" prop="imageIds" width="100">
                <template slot-scope="scope">
                  <el-form-item
                    v-if="viewJumpType == 'form'"
                    label="" label-width="0"
                    :prop="'tableList.'+scope.$index+'.imageIds'"
                    :rules="formArrayRules.imageIds" class="m-px-b-0"
                  >
                    <uploadFile
                      ref="uploadFile" :uploaderName="`image${scope.$index}`"
                      uploadType="image" :uploadBtn="viewJumpType == 'form'"
                      uploadImageClass="uploadVideoTableBox"
                      uploadListClass="uploadTableVideoListBox"
                      btnTitle="上传报告" btnType="primary"
                      :isAccept="true" :acceptArr="['.jpg','.png','.jpeg']"
                      :multiple="false" :limit="1" :showList="true"
                      :deleteBool="viewJumpType == 'form'"
                      :successList="scope.row.imageList"
                      @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,'form','form','tableList',scope.$index,'image')"
                      @getFileList="(data)=>getFileTableListMixins(data,'form','form','tableList',scope.$index,'image',false, '')"
                    />
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="图片多传" prop="imageMultipleIds" width="100">
                <template slot-scope="scope">
                  <el-form-item
                      v-if="viewJumpType == 'form'"
                      label="" label-width="0"
                      :prop="'tableList.'+scope.$index+'.imageMultipleIds'"
                      :rules="formArrayRules.imageMultipleIds" class="m-px-b-0"
                  >
                    <uploadFile
                        ref="uploadFile" :uploaderName="`imageMultiple${scope.$index}`"
                        uploadType="image" :uploadBtn="viewJumpType == 'form'"
                        uploadImageClass="uploadVideoTableBox"
                        uploadListClass="uploadTableVideoListBox"
                        btnTitle="上传报告" btnType="primary"
                        :isAccept="true" :acceptArr="['.jpg','.png','.jpeg']"
                        :multiple="false" :limit="1" :showList="true"
                        :deleteBool="viewJumpType == 'form'"
                        :successList="scope.row.imageMultipleList"
                        @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,'form','form','tableList',scope.$index,'imageMultiple')"
                        @getFileList="(data)=>getFileTableListMixins(data,'form','form','tableList',scope.$index,'imageMultiple',false, '')"
                    />
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="文件单传" prop="annexIds" width="300">
                <template slot-scope="scope">
                  <el-form-item
                      v-if="viewJumpType == 'form'"
                      label="" label-width="0"
                      :prop="'tableList.'+scope.$index+'.annexIds'"
                      :rules="formArrayRules.annexIds" class="m-px-b-0"
                  >
                    <uploadFile
                        ref="uploadFile" :uploaderName="`annex${scope.$index}`"
                        uploadType="btnList" :uploadBtn="viewJumpType == 'form'"
                        btnTitle="上传" btnType="primary"
                        :isAccept="true" :acceptArr="['.rar','.zip','.doc','.docx','.pdf','.xls','.xlsx','.jpg','.png','.jpeg']"
                        :multiple="true" :limit="1" :showList="true"
                        :deleteBool="viewJumpType == 'form'"
                        :successList="form.annexList"
                        @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','tableList',scope.$index,'annex')"
                        @getFileList="(data)=>getFileTableListMixins(data,false,'form','tableList',scope.$index,'annex',true, '')"
                    />
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column label="文件多传" prop="annexMultipleIds" width="300">
                <template slot-scope="scope">
                  <el-form-item
                      v-if="viewJumpType == 'form'"
                      label="" label-width="0"
                      :prop="'tableList.'+scope.$index+'.annexMultipleIds'"
                      :rules="formArrayRules.annexMultipleIds" class="m-px-b-0"
                  >
                    <uploadFile
                        ref="uploadFile" :uploaderName="`annexMultiple${scope.$index}`"
                        uploadType="btnList" :uploadBtn="viewJumpType == 'form'"
                        btnTitle="上传" btnType="primary"
                        :isAccept="true" :acceptArr="['.rar','.zip','.doc','.docx','.pdf','.xls','.xlsx','.jpg','.png','.jpeg']"
                        :multiple="true" :limit="1" :showList="true"
                        :deleteBool="viewJumpType == 'form'"
                        :successList="form.annexMultipleList"
                        @deleteFileList="(data,deleteAnnexIdsBool)=>deleteFileTablelistMixins(data,deleteAnnexIdsBool,false,'form','tableList',scope.$index,'annexMultiple')"
                        @getFileList="(data)=>getFileTableListMixins(data,false,'form','tableList',scope.$index,'annexMultiple',true, '')"
                    />
                  </el-form-item>
                </template>
              </el-table-column>

              <el-table-column v-if="viewJumpType == 'form'" label="操作" align="center" width="100" fixed="right">
                <template slot-scope="scope">
                  <el-button type="text" typeC="danger"
                             @click="handleTableListDelete(scope.$index, scope.row)"
                  >删除
                  </el-button>
                </template>
              </el-table-column>
              <!-- 列表缺省 -->
              <div slot="empty" class="zjm_no_data_table_list height-100 flex row-center col-center">
                <el-empty :image-size="70" description="暂无数据"></el-empty>
              </div>
            </el-table>
            <el-button
                v-if="viewJumpType=='form'"
                class="bor-main-dotted-1  width-100 m-px-t-20"
                @click="handleTableListAdd()"
            >
              <i class="el-icon-plus"></i>
              添加
            </el-button>
          </el-col>
        </el-row>
      </div>
    </el-form>
    <div class="formBtn m-rem-b-0">
      <el-button v-if="viewJumpType == 'form'" type="primary" size="small" @click="submitForm">保存</el-button>
      <el-button size="small" @click="resetFormMixins">取消</el-button>
    </div>
  </div>
</template>
<script>
// 混入
import { formMixins } from '@/mixins/publicMixins/formMixins'
// -------------------------------------------------------------
export default {
  name: 'BookForm',
  mixins: [formMixins],
  components: { },
  inject: ['viewJumpType'],
  provide() {
    return {
      provideAll: this
    }
  },
  data() {
    return {
      // ID
      id: this.$route_query.id,
      // Form
      form: {
        input: null,
        digit: null,
        singleSelect: null, // '0'
        multipleSelect: null, // ['1','2']
        radio: null, // '0'
        checkbox: [], // ['1','2']
        date: null,
        time: null,
        remark:null,
        content:null,
        imageList: [],
        imageIds: [],
        imageMultipleList: [],
        imageMultipleIds: [],
        annexList: [],
        annexIds: [],
        annexMultipleList: [],
        annexMultipleIds: [],
        annexOneList: [],
        annexOneIds: [],
        tableList: [
          {
            input: null,
            digit: null,
            singleSelect: null, // '0'
            multipleSelect: null, // ['1','2']
            radio: null, // '0'
            checkbox: [], // ['1','2']
            imageList: [],
            imageIds: [],
            imageMultipleList: [],
            imageMultipleIds: [],
            annexList: [],
            annexIds: [],
            annexMultipleList: [],
            annexMultipleIds: []
          }
        ]
      },
      // form表单验证
      rules: {
        input: [{ required: true, message: '请输入输入框', trigger: 'blur' }],
        digit: [{ required: true, message: '请输入输入数字', trigger: 'blur' }],
        singleSelect: [{ required: true, message: '请选择下拉选择(单选)', trigger: 'change' }],
        multipleSelect: [{ required: true, message: '请选择下拉选择(多选)', trigger: 'change' }],
        radio: [{ required: true, message: '请选择单选框', trigger: 'change' }],
        checkbox: [{ required: true, message: '请选择复选框', trigger: 'change' }],
        date: [{ required: true, message: '请选择日期', trigger: 'change' }],
        time: [{ required: true, message: '请选择时间', trigger: 'change' }],
        remark: [{ required: true, message: '请输入备注', trigger: 'blur' }],
        imageIds: [{ required: true, message: '请上传单传一张', trigger: 'change' }],
        imageMultipleIds: [{ required: true, message: '请上传多传', trigger: 'change' }],
        annexIds: [{ required: true, message: '请上传上传单传一个', trigger: 'change' }],
        annexMultipleIds: [{ required: true, message: '请上传多传', trigger: 'change' }],
        annexOneId: [{ required: true, message: '请上传', trigger: 'change' }]
      },
      // 表单表格属性验证
      formArrayRules: {
        input: [{ required: true, message: '请输入输入框', trigger: 'blur' }],
        digit: [{ required: true, message: '请输入输入数字', trigger: 'blur' }],
        singleSelect: [{ required: true, message: '请选择下拉选择(单选)', trigger: 'change' }],
        multipleSelect: [{ required: true, message: '请选择下拉选择(多选)', trigger: 'change' }],
        date: [{ required: true, message: '请选择日期', trigger: 'change' }],
        time: [{ required: true, message: '请选择时间', trigger: 'change' }],
        imageIds: [{ required: true, message: '请上传单传一张', trigger: 'change' }],
        imageMultipleIds: [{ required: true, message: '请上传多传', trigger: 'change' }],
        annexIds: [{ required: true, message: '请上传上传单传一个', trigger: 'change' }],
        annexMultipleIds: [{ required: true, message: '请上传多传', trigger: 'change' }],
        content: [{ required: true, msg: '富文本编辑器', validator: (rule, value, callback) => this.wangEitorFun(rule, value, callback, 'wangEitor'), trigger: 'blur' }]
      },
      // 模仿 字典数据
      singleSelectOptions: [], // 业务类型
      // 处理附件回显
      AnnexList: [] // 会显示是的文件赋值
    }
  },

  mounted() {
    // 业务类型 字典
    this.getDictMixins('singleSelectOptions', 'sys_user_sex')
    if (this.id) {
      this.detailApi(this.id)
    }
  },
  methods: {
    /**
     * @description: 触发 合同清单 删除
     * @param {*} tableIndex // 需要删除的下标
     * @author: 张佳敏
     */
    handleTableListDelete(tableIndex) {
      if (this.form.tableList.length > 4) {
        this.$confirm('确认要删除该选项吗?', '警告', {
          confirmButtonText: '确定',
          cancelButtonText: '取消',
          type: 'warning'
        }).then(() => {
          this.form.tableList.splice(tableIndex, 1)
          this.mixinDoLayoutHandle('tableList')
          this.msgAlt('删除成功', 'success')
        }).catch(() => {
          this.msgAlt('已取消删除', 'info')
        })
      } else if (this.form.tableList.length == 1) {
        this.msgAlt('至少有一条数据', 'error')
      }
    },

    /**
     * @description: 触发 表格 添加
     * @author: 张佳敏
     */
    handleTableListAdd() {
      this.form.tableList.push({
        input: null,
        digit: null,
        singleSelect: null, // '0'
        multipleSelect: null, // ['1','2']
        date: null,
        time: null,
        imageList: [],
        imageIds: [],
        imageMultipleList: [],
        imageMultipleIds: [],
        annexList: [],
        annexIds: [],
        annexMultipleList: [],
        annexMultipleIds: []
      })
      this.mixinDoLayoutHandle('tableList')
    },

    /**
    * @description: 保存
    * @Author: baoxuhui
    * @return {*}
    */
    submitForm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          let url = null; let type = null
          if (this.$route_query.id) {
            url = '/question-bank/update'
            type = '修改'
          } else {
            url = '/question-bank/save'
            type = '新增'
          }
          this.saveOrUpdateMixins(url, this.form, type)
        }
      })
    },

    /**
     * @description: 调取详情
     * @Author: baoxuhui
     * @param {*} id // 入参
     * @return {*}
     */
    detailApi(id) {
      const data = {
        id: id
      }
      const url = '/question-bank/get'
      this.getDetailMixins(url, data)
    },

    /**
     * @description: 详情回显
     * @Author: baoxuhui
     * @param {*} res // 数据
     * @return {*}
     */
    formDetail(res) {
      const data = this.filesArryMixins(res.data)// 有附件时需要调取赋值
      if(this.$refs.wangEitor){
        this.$refs.wangEitor.html = res.data.content
      }
      this.form = data
      this.formLoading = false
    }
  }
}
</script>
